package com.example.onlinemarket.model;

import java.util.ArrayList;
import java.util.List;

public class MobileOrderInfo {
    public int orderId;
    public String address;
    public String note;
    public List<MobileOrderItemInfo> orderItemInfoList;

    public MobileOrderInfo() {
    }

    public MobileOrderInfo(OrderInfo info) {
        this.orderId = info.order.getOrderId();
        this.address = info.order.getAddress();
        this.note = info.order.getNote();
        orderItemInfoList = new ArrayList<>();
        for(MobileOrderItem item:info.orderItemList){
            orderItemInfoList.add(new MobileOrderItemInfo(item.goodId, item.goodNum));
        }
    }

    public static List<MobileOrderInfo> getMobileOrderInfoList(List<OrderInfo> orderInfos){
        List<MobileOrderInfo> orderInfoList = new ArrayList<>();
        for(OrderInfo info:orderInfos){
            orderInfoList.add(new MobileOrderInfo(info));
        }
        return orderInfoList;
    }
}
